#ifndef AD_CONTENT_CLASS
#define AD_CONTENT_CLASS 
#include <string>
#include <iostream>
#include <highgui.h>
#include <cv.h>
#include <imgcodecs.hpp>
#include <imgproc.hpp>
#include <unordered_map>
#include <time.h>

using namespace std;
using namespace cv;
//description of an ad
struct AdContent{
	Mat originalImg;
	vector<Mat> YUV;
	Mat dctImg;
	//code info for water mark embeding
	int k1[24];
	int k2[24];
	AdContent(Mat original){
		//initialize originalImg
		original.copyTo(originalImg);
		//initialize YUV
		Mat originalYUV;
		cvtColor(original, originalYUV, CV_BGR2YUV);
		YUV.resize(3);
		split(originalYUV, YUV);
		//from RGB->YUV and process Y channel
		//initialize dctImg
		Mat originalY = YUV[0];

		int wStep = original.cols / 8;
		int hStep = original.rows / 8;

		dctImg = Mat(original.rows, original.cols, CV_64FC1);

		for (int i = 0; i < wStep; i++)
		for (int j = 0; j < hStep; j++){

			Rect roiRect(i * 8, j * 8, 8, 8);
			Mat roi = Mat(originalY, roiRect);

			Mat roiDst(8, 8, CV_64FC1);
			dct(roi, roiDst);

			Mat roi_of_dctDst(dctImg, roiRect);
			roi_of_dctDst = roiDst;
		}
		//initialize k1,k2
		srand((unsigned)time(NULL));
		for (int i = 0; i < 24; i++)
			k1[i] = rand() % 24;
		for (int i = 0; i < 24; i++)
			k2[i] = rand() % 24;


	}
};

//store all ads
class ActivityContent{
private:
	unordered_map<long long, AdContent*> ads;
	friend class WaterMark;
public:
	//insert an ad content
	bool insertAdContent(Mat& newAdImage, long long adId);
	//delete an ad content
	bool deleteAdContent(long long adId);
	//search an ad and return its content
	pair<AdContent*, bool> searchAdContent(long long adId);
};
#endif